package com.pan.games.array;

import com.sun.scenario.effect.impl.sw.sse.SSEBlend_SRC_OUTPeer;

import java.util.Arrays;

/**
 * 对于二维数组的形式
 * int[]中的元素依然为int[]
 * int[] arr = int[]{int[],int[],int[]}
 *
 * @author by panstark
 * @description
 * @notice
 * @date 2020/12/22
 */
public class BasicDDArrayPlayer {

    public static int[][] DDArray = new int[10][10];

    /**
     * [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
     * [10, 11, 12, 13, 14, 15, 16, 17, 18, 19]
     * [20, 21, 22, 23, 24, 25, 26, 27, 28, 29]
     * [30, 31, 32, 33, 34, 35, 36, 37, 38, 39]
     * [40, 41, 42, 43, 44, 45, 46, 47, 48, 49]
     * [50, 51, 52, 53, 54, 55, 56, 57, 58, 59]
     * [60, 61, 62, 63, 64, 65, 66, 67, 68, 69]
     * [70, 71, 72, 73, 74, 75, 76, 77, 78, 79]
     * [80, 81, 82, 83, 84, 85, 86, 87, 88, 89]
     * [90, 91, 92, 93, 94, 95, 96, 97, 98, 99]
     */
    static {
        for(int i=0;i<DDArray.length;i++){
            int[] row = DDArray[i];
            for(int j=0;j<row.length;j++){
                row[j]=i*10+j;
            }
        }
    }

    public static void swap(int[] index1,int[] index2){
        int index1Data =  DDArray[index1[0]][index1[1]];
        DDArray[index1[0]][index1[1]] = DDArray[index2[0]][index2[1]];
        DDArray[index2[0]][index2[1]]=index1Data;
    }

    public static void main(String[] args) {

        for (int[] ints : DDArray) {
            System.out.println(Arrays.toString(ints));
        }

        int[] index1 = new int[]{3,3};
        int[] index2 = new int[]{8,8};
        swap(index1,index2);
        for (int[] ints : DDArray) {
            System.out.println(Arrays.toString(ints));
        }
    }

}
